<template>
  <div class="container">
    <div class="search">
      <el-form :inline="true"  label-width="68px" size="small">
         <el-form-item label="角色名">
            <el-input v-model="searchData.name" placeholder="角色名"></el-input>
         </el-form-item>
      </el-form>
    </div>
    <div class="operation">
       <el-button type="primary" @click="search">搜索</el-button>
       <el-button type="primary" @click="handleAddRole">添加</el-button>
    </div>
    <el-table :data="listData" style="width: 100%" :height="578">
      <el-table-column prop="name" label="角色名">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.pageNumber"
      :page-sizes="[10,20, 50, 100, 500]"
      :page-size="page.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.total">
    </el-pagination>
  </div>
</template>

<script>
import api from '@/config/server.js'
export default {
  data () {
    return {
      listData: [],
      searchData: {
        name: ''
      },
      page: {
        pageNumber: 1,
        pageSize: 10,
        total: 0,
        totalPage: 0
      }
    }
  },
  created () {
    this.search()
  },
  methods: {
    search () {
      api.roleList({
        page: this.page.pageNumber - 1,
        size: this.page.pageSize,
        name: this.searchData.name,
        description: this.searchData.description
      }).then((res) => {
        this.listData = res.result.content
        this.page.pageNumber = res.result.pageable.pageNumber + 1
        this.page.pageSize = res.result.pageable.pageSize
        this.page.total = res.result.totalElements
        this.page.totalPage = res.result.totalPages
      })
    },
    handleSizeChange (val) {
      this.page.pageSize = val
      this.search()
    },
    handleCurrentChange (val) {
      this.page.pageNumber = val
      this.search()
    },
    currentPage () {

    }
  }
}
</script>

<style lang="scss" scoped>
  .container{
    padding: 10px 0 0 0 ;
  }
  .search{
    .el-form{
      width:100%;
      display:flex;
      flex-direction:row;
      justify-content:flex-start;
      flex-wrap:wrap;
      .el-form-item{
        width: 270px;
      }
    }
    width:100%;
  }
  .operation{
    margin-top:10px;
    float: left;
  }
  .el-tree{
    width:200px;
  }
  // .el-input {
  //   width: 200px;
  // }

</style>>
